package lambda;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.IntSummaryStatistics;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;

public class LambdaTest {

	public static void main(String[] args) {
		//				List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 7);
		//				list.forEach(n1 -> {
		//					System.out.println(n1);
		//					System.out.println("---------");
		//				});
		//list.forEach(System.out::println);
		LambdaInterface lif = (int a, String b) -> {
			System.out.println(a + b);
			return a + 1;
		};
		//		System.out.println(lif.exec(3, "lambda"));
		//		BiConsumer<Integer, String> b = (Integer x, String y) -> System.out.println(x + " : " + y);
		//		test(b);
		List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 7);

		//		list.stream().map((x) -> x * x).forEach(System.out::println);
		//		int sum;
		//		List<Integer> list2 = new ArrayList<>();
		//		list.forEach(n -> {
		//			System.out.println(n * n);
		//			int key = n+1;
		//			list2.add(n);
		//		});
		//		list2.forEach(n -> System.out.println(n));
		//		Comparator<Integer> comparator = (Integer a,Integer b) -> 0;
		//		List<Integer> list2 = list.stream().map(n->n*n).sorted((a,b)->b-a).collect(Collectors.toList());
		//		list2.forEach(n -> System.out.println(n));
		//		int i = list.stream().map(n->n*n).sorted((a,b)->b-a).max((a,b)->a-b).get();
		//		System.out.println(i);
		IntSummaryStatistics y = list.stream().map(n -> n * n).sorted((a, b) -> b - a).mapToInt(x -> x)
				.summaryStatistics();
		System.out.println(y.getAverage());
	}

	public static void test(BiConsumer<Integer, String> biConsumer) {

	}

	class pp implements LambdaInterface {

		@Override
		public int exec(int a, String b) {
			// TODO Auto-generated method stub
			return 0;
		}

	}
}
